using System;
using System.IO;
using System.Linq;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using MilkTeaMachine.OfflineClient.ViewModels;
using MilkTeaMachine.OfflineClient.Views;
using ReactiveUI;

namespace MilkTeaMachine.OfflineClient;

public partial class App : Application
{
    public static readonly string SharedResourceRootPath = Path.Combine(
        AppDomain.CurrentDomain.BaseDirectory,
        "SharedResource");

    public override void Initialize()
    {
        AvaloniaXamlLoader.Load(this);
    }

    public override void OnFrameworkInitializationCompleted()
    {
        if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
        {
            desktop.MainWindow = new BootWindow
            {
                DataContext = new BootViewModel(),
            };
        }


        base.OnFrameworkInitializationCompleted();
    }

    public static ushort GetComposedUshort(byte high, byte low)
    {
        byte[] @byte = [low, high];
        return BitConverter.ToUInt16(@byte, 0);
    }
}